package com.demo.auth.until;

import cn.hutool.core.util.StrUtil;
import com.demo.auth.common.constants.ImageConstants;
import com.demo.auth.entity.SmsCode;
import lombok.experimental.UtilityClass;

/**
 * 短信验证码生成类
 *
 * @author YT
 * @date 2019-06-20
 */
@UtilityClass
public class SmsCodeGenerator {

    public static SmsCode createSmsCode() {
        int expireIn = ImageConstants.CODE_EXPIREIN;
        // 生成短信验证码
        int code = (int) Math.ceil(Math.random() * 9000 + 1000);
        return new SmsCode(StrUtil.toString(code), expireIn);
    }
}
